package com.service.api;

import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;
//import org.jboss.netty.example.securechat.SecureChatSslContextFactory;
import org.jboss.netty.handler.codec.http.HttpClientCodec;
import org.jboss.netty.handler.codec.http.HttpContentDecompressor;

public class HttpClientPipelineFactory implements ChannelPipelineFactory {
	
	private final boolean ssl;
	
	public HttpClientPipelineFactory (boolean paramBoolean){
		this.ssl = paramBoolean;
	}
	
	public ChannelPipeline getPipeline() throws Exception {
		ChannelPipeline localChannelPipeline = Channels.pipeline();
		if (this.ssl) {
//			SSLEngine localSSLEngine = SecureChatSslContextFactory
//					.getClientContext().createSSLEngine();
//			localSSLEngine.setUseClientMode(true);
//			localChannelPipeline.addLast("ssl", new SslHandler(localSSLEngine));
		}
		localChannelPipeline.addLast("codec", new HttpClientCodec());
		localChannelPipeline.addLast("inflater", new HttpContentDecompressor());
		localChannelPipeline.addLast("handler", new HttpResponseHandler());
		return localChannelPipeline;
	}
}